package cn.fuck;

import java.util.Arrays;

enum Book {
    SMALL, MID, BIG;
}
enum Games {
    HALF("3"), REDALERT("raising");


    private String name;
    // 构造器不能是public, 且只在构造枚举常量时被调用
    Games(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    /*
     如果不重写, 则枚举类型返回枚举常量的名
    * */
    @Override
    public String toString() {
        return getName();
    }
}
public class TestEnum {
    public static void main(String[] args) {
//        System.out.println(Book.BIG);
//        System.out.println(Games.HALF);
        System.out.println(Games.REDALERT.toString());
        System.out.println(Enum.valueOf(Games.class, "REDALERT"));
        System.out.println(Arrays.toString(Games.values()));

        // 返回枚举常量在枚举类中的位置
        System.out.println(Book.MID.ordinal());
    }

}
